<template>
  <el-row>
    <el-col :span="24">
      <el-tabs v-model="activeName">
        <el-tab-pane label="服务信息" name="1">
          <keep-alive>
            <service-info v-if="activeName == 1" :orderDetail="orderDetail" :id="id">
              <div slot="tools" style="text-align: center;">
                <el-button type="primary" plain style="width: 120px;" @click="showOffer"> 支  付 </el-button>
              </div>
            </service-info>
          </keep-alive>
        </el-tab-pane>
        <el-tab-pane label="订单信息" name="2">
          <keep-alive>
            <order-info v-if="activeName == 2" :orderDetail="orderDetail" :id="id"></order-info>
          </keep-alive>
        </el-tab-pane>
        <el-tab-pane label="跟进记录" name="3">
          <keep-alive>
            <FollowUp v-if="activeName == 3" :id="id" :objectId="objectId" :objectType="objectType"></FollowUp>
          </keep-alive>
        </el-tab-pane>
        <el-tab-pane label="报价记录" name="4">
          <keep-alive>
            <quotation-record-info v-if="activeName == 4" :orderDetail="orderDetail"></quotation-record-info>
          </keep-alive>
        </el-tab-pane>
      </el-tabs>
      <div style="position: absolute; top: 0; right: 0;">
        <el-button type="primary" @click="showOffer">立即支付</el-button>
      </div>
    </el-col>
  </el-row>
</template>
<script>
import OrderInfo from '@/views/fhb/myOrders/components/info/OrderInfo'
import ServiceInfo from '@/views/fhb/myOrders/components/info/ServiceInfo'
import QuotationRecordInfo from '@/views/fhb/myOrders/components/info/QuotationRecordInfo'
import {unixTimestampFilter, filterDataBaseDictionary, decimalNumFilter} from '@/filters'
import FollowUp from '@/views/fhb/business/FollowUp'
export default {
  name: 'myOrdersCompletedShow',
  components: {
    FollowUp,
    OrderInfo,
    ServiceInfo,
    QuotationRecordInfo
  },
  filters: {
    decimalNumFilter,
    filterDataBaseDictionary,
    unixTimestampFilter
  },
  data() {
    return {
      id: this.$route.params.id,
      activeName: this.$route.query.tab ? String(this.$route.query.tab) : '1',
      objectId: this.$route.query.objectId ? String(this.$route.query.objectId) : '',
      objectType: this.$route.query.objectType ? String(this.$route.query.objectType) : '',
      orderDetail: {},
      autoEvaluationTime: 0,
      fhbOrderNodes: [],
      fhbOrder: {},
      fhbOrderBidding: {},
      fhbOrderGoods: [],
      fhbOrderConsigneeInfo: {},
      fhbOrderPickupInfo: {},
      fhbOrderBiddingLog: {},
      fhbOrderBiddingLogs: [],
      fhbOrderCollection: {},
      money: 0,
      goodsNum: 0,
      evalueForComplainTime: '',
      closeForComplainTime: '',
      isAbnormal: ''
    }
  },
  created() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      this.$ajax.get('/ms-fahuobao-order/FhbOrder/findFhbOrderParticulars', {orderId: this.id}).then(response => {
        if (!response.data) {
          return
        }
        this.orderDetail = response.data
        this.autoEvaluationTime = this.orderDetail.autoEvaluationTime
        this.fhbOrderNodes = this.orderDetail.fhbOrderNodes || []
        // this.fhbOrder = this.orderDetail.fhbOrder || {}
        this.fhbOrderBidding = this.orderDetail.fhbOrderBidding || {}
        this.fhbOrderGoods = this.orderDetail.fhbOrderGoods || []
        this.fhbOrderConsigneeInfo = this.orderDetail.fhbOrderConsigneeInfo || {}
        this.fhbOrderPickupInfo = this.orderDetail.fhbOrderPickupInfo || {}
        this.fhbOrderBiddingLog = this.orderDetail.fhbOrderBiddingLog || {}
        this.fhbOrderBiddingLogs = this.orderDetail.fhbOrderBiddingLogs || []
        // this.fhbOrderCollection = this.orderDetail.fhbOrderCollection || {}
        this.money = this.orderDetail.money
        for (let v of this.fhbOrderGoods) {
          this.goodsNum += (v.num ? parseInt(v.num) : 0)
        }
        this.evalueForComplainTime = this.orderDetail.evalueForComplainTime
        this.closeForComplainTime = this.orderDetail.closeForComplainTime
        this.isAbnormal = response.isAbnormal
      })
    },
    showOffer(data) {
      this.$router.push({path: '/ss-fhb/myOrders/pending/payment/' + this.id, query: {bid: this.fhbOrderBiddingLog.id}})
    }
  }
}
</script>
